#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
#include<sstream>

using namespace std;

map<string,string> dic;
string s,ans,s1,s2;

int main(){
		while(getline(cin,s)){
			if(s=="") break;
			stringstream ss(s);
			ss>>s1>>s2;
			dic[s2]=s1;
		}
		
		while(cin>>ans){
			if(dic.count(ans)){
				cout<<dic[ans]<<endl;
			}else{
				cout<<"eh"<<endl;
			}
		}
		return 0;
}
